package bbb.sss;

import java.util.HashMap;
import java.util.Map;

import bbb.Award;

public class Tester {
	
	public static void repeatRate(int count,int seedRange) {
		int i = 0;
		Map<Integer,Integer> mm = new HashMap<Integer, Integer>();
		while(i < count){
			Integer number = Utils.randomNumber(seedRange);
			if(mm.get(number) == null){
				mm.put(number, 1);
			}else{
				int c = mm.get(number);
				mm.put(number, c+1);
			}
			i++;
		}
		
		int c = 0;
		for(Integer key : mm.keySet()){
			if(mm.get(key) > 1){
				c++;
				System.out.println(key + " : " + mm.get(key));
			}
		}
		System.out.println("===========>"+c);
	}
	
	public static void stepTest(int seedRange) {
		int i = 0 ; 
		int stepAvg = 0;
		int beginAvg = 0;
		while(i < 1000){
			Map<Integer,Integer> mm = new HashMap<Integer, Integer>();
			int j = 0;
			while(true){
				Integer number = Utils.randomNumber(seedRange);
				if(mm.get(number) == null){
					mm.put(number, j);
				}else{
					int step = j - mm.get(number);
					stepAvg += step;
					beginAvg += j;
					System.out.println(j+" : " + step);
					break;
				}
				j++;
			}
			
			i++;
		}
		
		System.out.println("==================================================================");
		System.out.println(beginAvg  + " : " + stepAvg );
	}
	
	public static void printAwardRate(int count,double rate) {
		System.out.println(awardRate(count, rate));
	}

	public static double awardRate(int count,double rate) {
		return 1-Math.pow(1-rate, count);
	}
	
	public static void main(String[] args) {
//		int max = 1000;
//		
//		for(int count = 1 ; count <= max ; count++){
//			System.out.println(count+"  ==============================");
//			printAwardRate(count, Award.RATE_LEVEL_1);
//			printAwardRate(count, Award.RATE_LEVEL_2);
//			printAwardRate(count, Award.RATE_LEVEL_3);
//			printAwardRate(count, Award.RATE_LEVEL_4);
//			printAwardRate(count, Award.RATE_LEVEL_5);
//			printAwardRate(count, Award.RATE_LEVEL_6);
//			double total = 
//				awardRate(count, Award.RATE_LEVEL_1) * Award.RMB_LEVEL_1 + 
//				awardRate(count, Award.RATE_LEVEL_2) * Award.RMB_LEVEL_2 + 
//				awardRate(count, Award.RATE_LEVEL_3) * Award.RMB_LEVEL_3 + 
//				awardRate(count, Award.RATE_LEVEL_4) * Award.RMB_LEVEL_4 + 
//				awardRate(count, Award.RATE_LEVEL_5) * Award.RMB_LEVEL_5 + 
//				awardRate(count, Award.RATE_LEVEL_6) * Award.RMB_LEVEL_6 ;
//			System.out.println(count + " : " + total / count);
//		}
		
		for(int i = 1 ; i <= 30 ; i ++){
			System.out.print(i+"\t");//次数
			System.out.print(((int)Math.pow(2, i-1))+"\t");//个数
			System.out.print(((int)Math.pow(2, i))+"\t");//金额
			System.out.print(((int)(Math.pow(2, i-1)* 5))+"\t");//本次收益
			
			System.out.print(((int)Math.pow(2, i)-1)+"\t");//个数
			System.out.print(((int)Math.pow(2, i+1)-2)+"\t");//金额
			System.out.print(((int)(5*Math.pow(2, i-1)-2*(Math.pow(2, i)-1)))+"\t");//累计收益
			System.out.println(1-Math.pow(15.0/16.0, i)+"\t");//概率
		}
	}
}
